import Request from "@/common/utils/request/index";
import { PermissionVO } from "@/types/model/role/vos/role.vo";

enum Api {
  GetClientRolesList = "/jeecgboot/pos/permission/getClientRoles",
  GetAllClientPermissionsList = "/jeecgboot/pos/permission/getAllClientPermissions",
  AddRole = "/jeecgboot/pos/permission/addRole",
  EditRole = "/jeecgboot/pos/permission/editRole",
  GetPermissionsByRoleId = "/jeecgboot/pos/permission/getPermissionsByRoleId",
}

export const getClientRolesList = (params: any) => {
  return Request.getInstance().send({
    url: Api.GetClientRolesList,
    method: "GET",
    params,
  });
};

export const getAllClientPermissionsList = () => {
  return Request.getInstance().send<PermissionVO[]>({
    url: Api.GetAllClientPermissionsList,
    method: "GET",
  });
};

export const addRole = (params: any) => {
  return Request.getInstance().send({
    url: Api.AddRole,
    method: "POST",
    data: params,
  });
};

export const editRole = (params: any) => {
  return Request.getInstance().send({
    url: Api.EditRole,
    method: "POST",
    data: params,
  });
};

export const getPermissionsByRoleId = (roleId: string) => {
  return Request.getInstance().send({
    url: Api.GetPermissionsByRoleId,
    method: "GET",
    params: { roleId },
  });
};
